Skip to content

Add Indices of X in List #7323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
May 14, 2025
Merged

Conversation

Burbulinis
Copy link
Contributor

@Burbulinis Burbulinis commented Dec 29, 2024

Description

This PR aims to add an expression to get the indices or positions of a list where the value at that index is the provided value.
The indices option is only allowed for variable lists, which returns strings. Whereas for positions it returns an integer. You can get the position of any list. For example:

set {_list::a} to 1
set {_list::b} to 2
set {_list::c} to 1
set {_list::d} to 2
set {_list::e} to 1

send all indices of the value 2 in {_list::*} # returns "b" and "d"
send all positions of the value 1 in {_list::*} # returns 1, 3, 5

send positions of value {_whatever} in (some expression that returns multiple values)
# allows non-literals and non-variable lists

# also allows for strings:

send all positions of "a" in "abcabcabc" # returns 1, 4 and 7

send first/last position of "breh" in "whatever breh" 
# added support for the keyword 'position' and support to get all of the positions in the string

This expression was merged with the current ExprIndexOf, which I renamed for clarity. The default, if you do not specify last or all is the first index/position. This is done to be consistent with the old ExprIndexOf.

BREAKING CHANGE:

  • returning nothing instead of -1 for an unfound value in a String. (i.e. index of "a" in "b")

Target Minecraft Versions: any
Requirements: none
Related Issues: #3933

Copy link
Member

@Efnilite Efnilite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nois

@Efnilite Efnilite added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Dec 29, 2024
@Burbulinis Burbulinis requested a review from sovdeeth December 29, 2024 21:55
@Burbulinis Burbulinis requested a review from Moderocky December 30, 2024 12:21
@Moderocky Moderocky added the 2.10 label Dec 30, 2024
@Burbulinis Burbulinis requested a review from sovdeeth February 19, 2025 20:29
@Efnilite Efnilite added the breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) label Mar 12, 2025
@sovdeeth sovdeeth removed the feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. label Mar 21, 2025
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re request when tests fixed

@sovdeeth sovdeeth removed the 2.11 label Mar 29, 2025
@Burbulinis Burbulinis requested a review from a team as a code owner March 29, 2025 21:30
@Burbulinis Burbulinis requested review from Pikachu920 and removed request for a team March 29, 2025 21:30
@Burbulinis Burbulinis requested a review from sovdeeth March 29, 2025 21:47
@Burbulinis Burbulinis requested a review from sovdeeth May 7, 2025 10:07
@sovdeeth sovdeeth added the feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. label May 13, 2025
@sovdeeth sovdeeth merged commit fc51c90 into SkriptLang:dev/feature May 14, 2025
5 checks passed
@sovdeeth sovdeeth moved this to Done in 2.12 Release Jun 22, 2025
@sovdeeth sovdeeth linked an issue Jun 22, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Index of object in list expression
8 participants